﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using WeChat.Dto.Users;
using WeChat.IService;
using WeChat.Web.Models;

namespace WeChat.Web.Controllers
{
    public class HomeController : Controller
    {
        private readonly IUsersService _usersService;

        public HomeController(IUsersService usersService)
        {
            _usersService = usersService;
        }

        public async Task<IActionResult> Index()
        {
            await _usersService.CreateAsync(new CreateUsersInput() { UserName = "test", UserNick = "test1", UserPwd = "tttttt" });
            return View();
        }

        public async Task<IActionResult> Privacy()
        {
            var result = await _usersService.GetAllUserAsync();
            return Json(result);
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}
